<%@ page language="java" contentType="text/html; charset=UTF-8"%>
<%@ page import="java.util.*"%>
<%@ page import="java.text.SimpleDateFormat" %>
<%@ page import="net.board.db.*" %>

<%
	List boardList=(List)request.getAttribute("boardlist");
	int listcount=((Integer)request.getAttribute("listcount")).intValue();
	int nowpage=((Integer)request.getAttribute("nowpage")).intValue();
	int maxpage=((Integer)request.getAttribute("maxpage")).intValue();
	int startpage=((Integer)request.getAttribute("startpage")).intValue();
	int endpage=((Integer)request.getAttribute("endpage")).intValue();
	int number=((Integer)request.getAttribute("number"));
	
	String search = null;
	String searchword = "";
	
	String check1 = null;
	String check2 = null;
	String check3 = null;
	
	if((String)request.getAttribute("search") != null){
		search = (String)request.getAttribute("search");
		if(search.equals("qna_content")){
			check1 = "selected='selected'";
			check2 = "";
			check3 = "";
		}if(search.equals("qna_subject")){
			check1 = "";
			check2 = "selected='selected'";
			check3 = "";
		}if(search.equals("qna_nick")){
			check1 = "";
			check2 = "";
			check3 = "selected='selected'";
		}
	}
	if((String)request.getAttribute("searchword") != null){
		searchword = (String)request.getAttribute("searchword");
	}
System.out.println(search + " || " + searchword );
%>

<html>
<head>
	<title>Q&A掲示板</title>

<link rel="stylesheet" type="text/css" href="/KOMORIUTA/Mypage/Css/MpBord.css"> 
<style type="text/css">
a.black:link, a.black:visited, a.black:active{color: black; text-decoration:none;}
a.black:hover{text-decoration:underline;}
</style>


</head>

<body>
<!-- 게시판 리스트 -->
<form method="post" action="./BoardList.bo?number=<%=number%>">
<table width="700" cellpadding="0" cellspacing="0">
	<tr valign="middle" align="left">
		<th colspan="4">
			<img alt="" src="<%=request.getContextPath() %>/photo/img/Cm_Free_Qna.png">
		</th>
		<th align="right">
			<font size=2><img alt="" src="<%=request.getContextPath() %>/photo/img/Mybold_Num.png"> ${listcount }</font>
		</th>
	</tr>
	<tr bordercolor="red" valign="middle" style="border-color: red;"><th></th></tr>
	
	<tr>
		<td width="50" style="background-color: #f7f7f7; border-top: 2px solid #cbcbcb">
			<img alt="" src="<%=request.getContextPath() %>/photo/img/Cm_Free_Board_1.png">
		</td>
		<td width="415" align="center" style="background-color: #f7f7f7; border-top: 2px solid #cbcbcb">
			<img alt="" src="<%=request.getContextPath() %>/photo/img/Cm_Free_Board_2.png">
		</td>
		<td width="100" style="background-color: #f7f7f7; border-top: 2px solid #cbcbcb">
			<img alt="" src="<%=request.getContextPath() %>/photo/img/Cm_Free_Board_3.png">
		</td>
		<td width="80" align="center" style="background-color: #f7f7f7; border-top: 2px solid #cbcbcb">
			<img alt="" src="<%=request.getContextPath() %>/photo/img/Cm_Free_Board_4.png">
		</td>
		<td width="55" style="background-color: #f7f7f7; border-top: 2px solid #cbcbcb">
			<img alt="" src="<%=request.getContextPath() %>/photo/img/Cm_Free_Board_5.png">
		</td>
	</tr>
	
	<%
		if(boardList != null){
		for(int i=0;i<boardList.size();i++){
			BoardBean bl=(BoardBean)boardList.get(i);
	%>
	
	
	
	<tr align="center" valign="middle" height="25">
		
		<td height="23" style="border-bottom: 1px solid #e6e6e6">
			<%=bl.getID()%>
		</td>
		
		<td style="border-bottom: 1px solid #e6e6e6">
			<div align="left">
			<%if(bl.getQNA_LEV()!=0){ %>
				<%for(int a=0;a<=bl.getQNA_LEV()*2;a++){ %>
				&nbsp;
				<%} %>
				<img alt="" src="board/images/arrow.jpg">
			<%}else{ %>
				
			<%} %>
			
			<a href="./BoardDetailAction.bo?ID=<%=bl.getID()%>&number=<%=number%>" class=black>
				<%=bl.getQNA_SUBJECT()%>
			</a>
			</div>
		</td>
		
		
		
		<td style="border-bottom: 1px solid #e6e6e6">
			<div align="center"><%=bl.getQNA_NICK() %></div>
		</td>
		<td width="80" align="center" style="border-bottom: 1px solid #e6e6e6; font-size: 12px;">
			<div align="center"><%=bl.getQNA_DATE() %></div>
		</td>	
		<td style="border-bottom: 1px solid #e6e6e6">
			<div align="center"><%=bl.getQNA_READCOUNT() %></div>
		</td>
	</tr>
	<tr bgcolor="e6e6e6" align="center" valign="middle">
		<td colspan="5" style="height:1px;"></td>
	</tr>
	<%} 
		
	}%>
	
	
	
	
	<tr align="center" height="40" valign="middle">
		<td colspan=7 >
			<%if(nowpage<=1){ %>
			<img src="/KOMORIUTA/photo/img/Mybold_Be.png"/>&nbsp;
			<%}else{ %>
			<a href="./BoardList.bo?nowpage=<%=nowpage-1%>&number=<%=number%>&search=<%=search%>&searchword=<%=searchword%>" class=black>◀<img src="/KOMORIUTA/photo/img/Mybold_Be.png"/></a>&nbsp;
			<%} %>
			
			<%for(int a=startpage;a<=endpage;a++){
				if(a==nowpage){%>
				[<%=a %>]
				<%}else{ %>
				<a href="./BoardList.bo?nowpage=<%=a %>&number=<%=number%>&search=<%=search%>&searchword=<%=searchword%>" class=black>[<%=a %>]</a>&nbsp;
				<%} %>
			<%} %>
			
			<%if(nowpage>=maxpage){ %>
			<img src="/KOMORIUTA/photo/img/Mybold_Ne.png"/>
			<%}else{ %>
			<a href="./BoardList.bo?nowpage=<%=nowpage+1%>&number=<%=number%>&search=<%=search%>&searchword=<%=searchword%>" class=black><img src="/KOMORIUTA/photo/img/Mybold_Ne.png"/>▶</a>
			<%} %>
		</td>
	</tr>
	<tr height="40">
		<td colspan="4" align="center">
			<select name="search">
			<option value="qna_content" <%=check1%> >内容</option>
			<option value="qna_subject" <%=check2%> >タイトル</option>
			<option value="qna_nick" <%=check3%> >作成者</option>
			</select>
			<input type="text" name="searchword" value="<%=searchword%>"/>
			<input type="submit" class="btn_Search" value=""/>
		</td>
		<td>
	   		<a href="./BoardWrite.bo?number=<%=number%>" class=black><img src="/KOMORIUTA/photo/img/Cm_Free_Read_Write.png"/></a>
		</td>
	</tr>
</table>
</form>
</body>
</html>